package co.com.services.citas;

import javax.naming.NamingException;
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;

import co.com.smart.maestro.infraestructure.dto.CitasDTO;
import co.com.smart.session.DelegateContextEJB;

@Path("/SmartCitasServices")
public class CitasServices {
	
		@GET
		@Path("/getAllCitas")	
		@Produces(MediaType.APPLICATION_JSON)
		public Response getCitas() throws NamingException {
			return Response.ok(DelegateContextEJB.getCitaBeanLocal().consultarAllCitas())
			.header("Access-Control-Allow-Origin", "*")
			.header("Access-Control-Allow-Methods", "POST, GET, PUT, UPDATE, OPTIONS")
			.header("Access-Control-Allow-Headers", "Content-Type, Accept, X-Requested-With").build();
		}

		@POST
		@Path("/getCitasId")	
		@Produces(MediaType.APPLICATION_JSON)
		public Response getCitasId(CitasDTO json) throws NamingException {
			return Response.ok(DelegateContextEJB.getCitaBeanLocal().consultarCitasId(json))
			.header("Access-Control-Allow-Origin", "*")
			.header("Access-Control-Allow-Methods", "POST, GET, PUT, UPDATE, OPTIONS")
			.header("Access-Control-Allow-Headers", "Content-Type, Accept, X-Requested-With").build();
		}

		@PUT
		@Path("/setCitas")
		@Consumes(MediaType.APPLICATION_JSON)
		@Produces(MediaType.APPLICATION_JSON)
		public Response setCitas( CitasDTO json){ 
			return Response.ok(DelegateContextEJB.getCitaBeanLocal().insertarCitas(json))
					.header("Access-Control-Allow-Origin", "*")
					.header("Access-Control-Allow-Methods", "POST, GET, PUT, UPDATE, OPTIONS")
					.header("Access-Control-Allow-Headers", "Content-Type, Accept, X-Requested-With")
					.build();
		}

		@PUT
		@Path("/editCitas")
		@Consumes(MediaType.APPLICATION_JSON)
		@Produces(MediaType.APPLICATION_JSON)
		public Response setEditCitas(CitasDTO json){ 
			return Response.ok(DelegateContextEJB.getCitaBeanLocal().editCitas(json))
			.header("Access-Control-Allow-Origin", "*")
			.header("Access-Control-Allow-Methods", "POST, GET, PUT, UPDATE, OPTIONS")
			.header("Access-Control-Allow-Headers", "Content-Type, Accept, X-Requested-With").build();
		}

		@PUT
		@Path("/removeCitas")
		@Consumes(MediaType.APPLICATION_JSON)
		@Produces(MediaType.APPLICATION_JSON)
		public Response setRemoveCitas(CitasDTO json){ 
			return Response.ok(DelegateContextEJB.getCitaBeanLocal().removeCitas(json, true))
					.header("Access-Control-Allow-Origin", "*")
					.header("Access-Control-Allow-Methods", "POST, GET, PUT, UPDATE, OPTIONS")
					.header("Access-Control-Allow-Headers", "Content-Type, Accept, X-Requested-With").build();
		}


}
